package com.boco.webmaster.common.test.fixture;

import com.boco.transnms.server.dao.base.DaoHomeFactory;
import com.boco.transnms.common.cfg.ContextName;
import com.boco.transnms.server.common.cfg.TransNmsCfg;
import com.boco.transnms.server.bo.base.BoHomeFactory;
import com.boco.transnms.server.common.cfg.SystemEnv;

public final class DataSourceFixture {
    private DataSourceFixture() {
    }

    private static void loadCfgFile() throws Exception {
        String serverHome = SystemEnv.getPathEnv(SystemEnv.TNMS_SERVER_HOME);
        String cfgPath = serverHome + "/tnms-conf";
        System.out.println("cfgpath=" + cfgPath);
        TransNmsCfg.loadCfgFile(cfgPath + "/" + "tnmscfg.xml");
    }

    public static void initDataSource() throws Exception {
        loadCfgFile();
        DaoHomeFactory.getInstance().createDaoHome(ContextName.TRANSNMS_CONTEXT, new String[] {"wmdao.xml"});
        BoHomeFactory.getInstance().createBoHome(ContextName.TRANSNMS_CONTEXT, new String[] {"wmbo.xml"});
    }

}
